//
//  YEJLViewController.m
//  ShangChengMoBan
//
//  Created by yaoqi yaoqi on 16/11/1.
//  Copyright © 2016年 ping. All rights reserved.
//

#import "YEJLViewController.h"
#import "YE_jiLuTableViewCell.h"
@interface YEJLViewController ()<UITableViewDataSource,UITableViewDelegate>

@end

@implementation YEJLViewController
{
    RWScrollView * _table;
    int _page;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    _page = 1;
    [self drawNavWithTitle:@"记录" WithColor:[UIColor colorWithHue:0.00 saturation:0.00 brightness:1.00 alpha:1.00]];
    [self drawBackButton];
    _table = [[RWScrollView alloc]initWithFrame:CGRectMake(0, 64, KScreenWidth, KScreenHeight-64) style:UITableViewStyleGrouped];
    _table.delegate = self;
    _table.dataSource = self;
    [_table addHeaderWithTarget:self action:@selector(headRefresh)];
    [_table addFooterWithTarget:self action:@selector(footerRefresh)];
    [_table headerBeginRefreshing];
    _table.separatorStyle = UITableViewCellSelectionStyleNone;
    [_table registerClass:[YE_jiLuTableViewCell class] forCellReuseIdentifier:@"cell"];
    [self.view addSubview:_table];
}
-(void)headRefresh{
    _page = 1;
    [self requestDataWith:1];
}
-(void)footerRefresh{
    _page ++;
    [self requestDataWith:0];
}
-(void)requestDataWith:(int)first{
    NSMutableDictionary * requestDic = [[NSMutableDictionary alloc]init];
    [requestDic setObject:@"10" forKey:@"pageSize"];
    [requestDic setObject:[NSString stringWithFormat:@"%d",_page] forKey:@"pageNum"];

[NetWorking NEWjieKouQingQiu:@"" ANDIP:IP And:requestDic anBlock:^(NSDictionary *dic, NSError *error) {
    [_table headerEndRefreshing];
    [_table footerEndRefreshing];
    if (!error) {
        if ([requestDic[Code] intValue] == 200) {
            
        }
    }
}];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 3;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 3;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 30;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.1;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UILabel * lab = [[UILabel alloc]initWithFrame:CGRectMake(10, 5, 300, 20)];
    lab.text = @"2016-10-30";
    lab.font = [UIFont systemFontOfSize:13];
    lab.textColor = [UIColor lightGrayColor];
    return lab;
}
-(UITableViewCell * )tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    YE_jiLuTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 65;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
